<template>
  <el-card>
    <el-row :gutter="20">
      <el-col :span="10">
        <el-input
          placeholder="请输入内容"
          class="input-with-select"
          v-model="reqData.query"
        >
          <el-button slot="append" icon="el-icon-search" @click="sreach">
          </el-button>
        </el-input>
      </el-col>
      <el-col :span="4">
        <el-button type="primary" @click="openDialog">添加用户</el-button>
      </el-col>
      <el-dialog title="添加用户" :visible.sync="Isdialog">
        <el-form 
        :rules="verifyRules" 
        label-width="80px"
        :model="userForm"
        ref="userForm"
        >
          <el-form-item label="用户名称" prop="username">
            <el-input autocomplete="off" v-model="userForm.username"></el-input>
          </el-form-item>
          <el-form-item label="密码" prop="password">
            <el-input autocomplete="off" type="password"></el-input>
          </el-form-item>
          <el-form-item label="邮箱" prop="email">
            <el-input autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item label="手机" prop="phone">
            <el-input autocomplete="off" ></el-input>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="openDialog">取 消</el-button>
          <el-button type="primary" @click="openDialog">确 定</el-button>
        </div>
      </el-dialog>
    </el-row>
  </el-card>
</template>

<script>
export default {
  data() {
    return {
      reqData: {
        query: "",
        pagenum: 1,
        pagesize: 1,
      },
      userForm:{
        username:'',
        password:'',
        email:'',
        phone:''
      },
      Isdialog: false,
      verifyRules: {
        username: [
          { required: true, message: "请输入用户名字", trigger: "blur" },
          { min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur" },
        ],
        password:[
          { required: true, message: "请输入密码", trigger: "blur" },
          { min: 3, max: 8, message: "长度在 3 到 8 个字符", trigger: "blur" },
        ],
        email:[
          { required: true, message: "请输入邮箱名称", trigger: "blur" },
          { min: 3, max: 8, message: "长度在 3 到 8 个字符", trigger: "blur" },
        ],
        phone:[
          { required: true, message: "请输入手机号码", trigger: "blur" },
          { min: 6, max: 10, message: "长度在 6 到 10 个字符", trigger: "blur" },
        ]
      },
    };
  },
  methods: {
    sreach() {
      this.$store.dispatch("getUser", this.reqData);
    },
    openDialog() {
      this.Isdialog = !this.Isdialog;
    },
  },
};
</script>

<style>
</style>